import request from '@/utils/request'
import MapUtils from '@/utils/mapUtils'
// 查询房间表列表
export function listRoom(query) {
  return request({
    url: '/system/room/list',
    method: 'get',
    params: query
  }).then(response => {
    // 成功获取数据后设置房间映射
    if (response.code === 200 && response.rows) {
      MapUtils.setRoomMap(response.rows);
    }
    return response;
  });
}

// 查询房间表详细
export function getRoom(id) {
  return request({
    url: '/system/room/' + id,
    method: 'get'
  })
}

// 新增房间表
export function addRoom(data) {
  return request({
    url: '/system/room',
    method: 'post',
    data: data
  })
}

// 修改房间表
export function updateRoom(data) {
  return request({
    url: '/system/room',
    method: 'put',
    data: data
  })
}
// 修改房间表状态
export function updateRoomStatus(id) {
  return request({
    url: `/system/room/status?id=${id}`,
    method: 'put',
    
  })
}

// 删除房间表
export function delRoom(id) {
  return request({
    url: '/system/room/' + id,
    method: 'delete'
  })
}
